public class Jingyang {
    // 区域温度（含打开关闭连接）
    private native String getAreaTemperature(String ip, int port, String user, String pwd, int channel, int areaOperType);
    // 初始化SDK
    private native int initSdk();
    // 释放SDK
    private native int releaseSdk();
    // 打开连接
    private native int openConn(String ip, int port, String user, String pwd);
    // 关闭连接
    private native int closeConn(int handle);
    // 连接状态，0打开，-1关闭
    private native int isOpeningConn(int handle);
    // 区域温度（不关闭连接）
    private native String getAreaTemperatureByHandle(int handle, int channel, int areaOperType);

    // 引用库
    static { System.loadLibrary("jingyang"); }

    public static void main(String[] args) {
        System.out.println("1");
        Jingyang t = new Jingyang();
        System.out.println("2");
        // 获取温度（含打开关闭连接）
        // String jsonStr = t.getAreaTemperature("192.168.10.77", 30001, "admin", "admin", 1, 3);
        System.out.println ("初始化SDK");
        t.initSdk();
        System.out.println ("打开连接");
        int handle = t.openConn("192.168.10.77", 30001, "admin", "admin");
        System.out.println ("检查连接状态");
        if (t.isOpeningConn(handle) != 0) {
            System.out.println ("连接已关闭，重新打开连接");
            handle = t.openConn("192.168.10.77", 30001, "admin", "admin");
        }
        System.out.println ("获取温度");
        String jsonStr = t.getAreaTemperatureByHandle(handle, 1, 3);
        System.out.println (jsonStr);
        System.out.println ("关闭连接");
        t.closeConn(handle);
        System.out.println ("释放SDK");
        t.releaseSdk();
    }
}